import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)

import axios from 'axios'
axios.defaults.baseURL = 'http://localhost:8000/'
Vue.prototype.axios = axios

import ElementUi from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUi)

Vue.config.productionTip = false


// 白名单
// router.beforeEach((to, from, next) =>{
//   var white = ['/login', '/bindMobile', '/is']
//   if (white.indexOf(to.path) >= 0){
//     next()
//   } else {
//     var token = localStorage.token
//     if (token) {
//       next()
//     } else {
//       router.push('/login')
//     }
//   }
// })

// 拦截器
axios.interceptors.request.use(config =>{
  console.log('请求前的拦截器：', config)
  var token = localStorage.token
  if (token){
    config.headers['token'] = token
  }
  return config
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
